package com.csy.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ktt.bean.Bis_custom_user;
import com.sjh.mapper.IBag_mapper;
import com.sjh.service.IBag_service;
import com.sjh.vo.Bis_bag_record;
import com.sjh.vo.Bis_bisiness_order;
import com.sjh.vo.Bis_nurse_bag;


	@Controller
	@RequestMapping("wechat")
	public class BagController {
		@Autowired
		IBag_mapper mapper;
		@Autowired
		IBag_service bag_service;
		
		//礼包详情
		@RequestMapping("/GoshowBagDetail")
		public String showDetail(@RequestParam("bag_id") String bag_id,Model model){
			Bis_nurse_bag bag = bag_service.bagupdByid(bag_id);
			System.out.println("礼包详情: "+ bag);
			model.addAttribute("bag",bag);
			return "/csy/wechat/bag/showBagDetail";
		}
		
		
		
		//微信进入我的大礼包
		@RequestMapping("/GomyBag")
		public String GomyBag(Model model){
			List<Bis_nurse_bag> list=mapper.selectBis_nurse_bag();
			model.addAttribute("list", list);
			System.out.println("list11111"+list);
			return "/csy/wechat/bag/myBag";
		}
		
		//用来显示我的礼包的平台
		@RequestMapping("/Gobag1")
		@ResponseBody
		public List<Bis_bag_record> GoBag1(Model model,HttpSession session){
			Bis_custom_user ss=(Bis_custom_user) session.getAttribute("list");
			String custom_user_id=ss.getCustom_user_id();
			List<Bis_bag_record> list =bag_service.selectBis_bag_record(custom_user_id);
			System.out.println("111111-----------"+list);
			return list;
		}	
		
		//已拆礼包
		@RequestMapping("/GomyProject")
		public String GomyProject(){
			return "/csy/wechat/project/myProject";
		}
		//用来显示微信平台我的礼包详情
		@RequestMapping("/GoProject")
		@ResponseBody
		public List<Bis_bag_record> GoProject(Model model,HttpSession session){
			System.out.println("---------------------------------");
			Bis_custom_user ss=(Bis_custom_user) session.getAttribute("list");
			String custom_user_id=ss.getCustom_user_id();
			List<Bis_bag_record> bis_project_record=bag_service.selectBis_bag_record(custom_user_id);
			for (Bis_bag_record a : bis_project_record) {
				System.out.println("3222222222:    "+a.getBis_nurse_bag().getBag_name());
			}
			return bis_project_record;
		}
		
		
		//微信进入我的订单
		@RequestMapping("/GomyOrder")
		public String GomyOrder(){
			return "/csy/wechat/my/order/myOrder";
		}
		//用来显示微信平台进入我的订单
		@RequestMapping("/GoOrder")
		@ResponseBody
		public List<Bis_bisiness_order> GoOrder(HttpSession session){
			Bis_custom_user ss=(Bis_custom_user) session.getAttribute("list");
			Map<String, Object> map=new HashMap<>();
			map.put("custom_user_id", ss.getCustom_user_id());
			List<Bis_bisiness_order> bis_business_order=bag_service.selectBis_bisiness_order(map);
			for (Bis_bisiness_order a : bis_business_order) {
				System.out.println(a.getCustom_user_id()+":"+a.getShop().getShop_name()+":"+a.getOrder_status());
			}
			return bis_business_order;
		}
		
		//微信平台进入我的颜值ֵ
		@RequestMapping("/GomyBeauty")
		public String GomyBeauty(){
					
			return "/csy/wechat/my/myBeauty";
		}
		//微信平台进入我的收藏
		@RequestMapping("/GomyShopCollect")
		public String GomyShopCollect(){
					
			return "/csy/wechat/my/myShopCollect";
		}
}
